<template>
    <view>
        <view class="topbar" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor">
            <text @tap="topbarFn" :class="'item ' + (currentTab == index ? 'active' : '')" :data-idx="index" v-for="(item, index) in topbar" :key="index">{{ item }}</text>
        </view>
        <block v-if="currentTab == 0">
            <view class="my_hn_yes" v-if="ARR.hn_truename != ''">
                <view class="admid">
                    <view class="em hnpic" :style="'border-color:' + color">
                        <image :src="ARR.path_s_url"></image>
                        <text class="b" :style="'background-color:rgba(' + rgbcolor + ',.8)'">专属情感顾问</text>
                    </view>
                    <view class="font" :style="'color:' + color + ';'">{{ ARR.hn_truename }}，工号：{{ ARR.admid }}</view>
                </view>
                <view class="agenttitle" v-if="ARR.agenttitle != ''">来自：{{ ARR.agenttitle }}</view>
                <image class="ewm" :showMenuByLongpress="true" :src="ARR.hn_ewm_url"></image>
                <view class="h5 C999">长按二维码加情感顾问微信</view>
                <view @tap="telFn" class="hn_mob" :data-tel="ARR.hn_mob" :style="'color:' + color + ';'" v-if="ARR.hn_mob != ''">
                    <text class="i ico"></text>
                    <text class="tel">{{ ARR.hn_mob }}</text>
                </view>
            </view>
            <view class="my_hn_no" v-else>
                <view class="h4">您暂时还没有专属情感顾问</view>
                <image class="ewm" :showMenuByLongpress="true" :src="ARR.kf_wxpic_url"></image>
                <view class="h5 C999">长按二维码加客服微信咨询</view>
                <view @tap="telFn" :data-tel="ARR.kf_mob" v-if="ARR.kf_mob != ''">
                    <text class="i ico"></text>
                    <text class="tel">{{ ARR.kf_mob }}</text>
                </view>
                <view @tap="hnFn" class="a btn5" :style="'--color:' + color + ';--rgbcolor:' + rgbcolor">
                    <text class="i ico"></text>
                    情感顾问服务大厅
                </view>
            </view>
        </block>
        <block v-else-if="currentTab == 1 || currentTab == 2">
            <view class="my_qxyj_info">
                <view class="a">
                    <view class="i ico success">
                        <text class="em">
                            <text class="b">{{ NUM.num1 }}</text>
                            次
                        </text>
                    </view>
                    <text class="span">{{ NUM.str1 }}</text>
                </view>
                <view class="a">
                    <view class="i ico doing">
                        <text class="em">
                            <text class="b">{{ NUM.num2 }}</text>
                            次
                        </text>
                    </view>
                    <text class="span">{{ NUM.str2 }}</text>
                </view>
                <view class="a">
                    <view class="i ico fail">
                        <text class="em">
                            <text class="b">{{ NUM.num3 }}</text>
                            次
                        </text>
                    </view>
                    <text class="span">{{ NUM.str3 }}</text>
                </view>
            </view>
            <view class="my_hn_qx" v-if="LIST.length > 0">
                <view class="ul" v-for="(item, idx_dl) in LIST" :key="idx_dl">
                    <navigator class="li" hoverClass="none" :url="'/pagesA/u/u?uid=' + item.uid">
                        <image class="s" mode="aspectFill" :src="item.photo_s_url"></image>
                        <view class="em">
                            <image class="ugrade1" :src="item.grade_ico"></image>
                            <text class="font">{{ item.nickname }}</text>
                        </view>
                    </navigator>

                    <view class="li">
                        <view class="h5">{{ item.addtime }}</view>
                        <text class="i ico"></text>
                        <view class="span">
                            <view class="font" :style="'color:' + item.color">{{ item.flag_str }}</view>
                        </view>
                    </view>

                    <navigator class="li" hoverClass="none" :url="'/pagesA/u/u?uid=' + item.uid2">
                        <image class="s" mode="aspectFill" :src="item.photo_s_url2"></image>
                        <view class="em">
                            <image class="ugrade1" :src="item.grade_ico2"></image>
                            <view class="font">{{ item.nickname2 }}</view>
                        </view>
                    </navigator>
                </view>
            </view>
            <view class="nodata" v-if="LIST.length == 0">
                <image mode="aspectFit" src="/static/res/img/nodata.png"></image>
                暂无信息
            </view>
        </block>
    </view>
</template>

<script>
var t;
var n = require('../../res/www.a9a.cn.js');
var app = getApp();
export default {
    data() {
        return {
            topbar: ['我的顾问', '牵线记录', '约见记录'],
            currentTab: 0,
            color: '',
            rgbcolor: '',

            ARR: {
                hn_truename: '',
                path_s_url: '',
                admid: '',
                agenttitle: '',
                hn_ewm_url: '',
                hn_mob: '',
                kf_wxpic_url: '',
                kf_mob: ''
            },

            NUM: {
                num1: '',
                str1: '',
                num2: '',
                str2: '',
                num3: '',
                str3: ''
            },

            LIST: '',
            idx_dl: 0
        };
    },
    onLoad: function (o) {
        var that = this;
        app.globalData.chklogin().then(function (t) {
            t || uni.navigateBack();
        });
        app.globalData.get_openid().then(function (c) {
            that.setData({
                color: app.globalData._ZEAI.color,
                rgbcolor: n.c16_rgb(app.globalData._ZEAI.color)
            });
            t = uni.getStorageSync('COOK_U');
            var r = o.currentTab;
            if (!app.globalData.empty(r) && r > 0) {
                that.setData({
                    currentTab: r
                });
                that.get_data(r);
            }
            app.globalData.ajax({
                url: 'my_hongniang.php',
                data: {
                    submitok: 'index',
                    openid: t.openid
                },
                success: function (t) {
                    if (1 == t.flag) {
                        that.setData({
                            ARR: t.ARR
                        });
                    } else {
                        uni.showModal({
                            content: t.msg,
                            confirmColor: that.color,
                            confirmText: '朕知道了',
                            showCancel: false,
                            success: function (t) {
                                uni.switchTab({
                                    url: 'my'
                                });
                            }
                        });
                    }
                }
            });
        });
    },
    onShow: function () {},
    methods: {
        topbarFn: function (t) {
            var n = parseInt(t.currentTarget.dataset.idx);
            this.setData({
                currentTab: n
            });
            if (n > 0) {
                this.get_data(n);
            }
        },

        telFn: function (t) {
            var n = t.currentTarget.dataset.tel;
            uni.makePhoneCall({
                phoneNumber: n
            });
        },

        get_data: function (n, o) {
            app.globalData.chklogin().then(function (t) {
                t || uni.navigateBack();
            });
            var that = this;
            t = uni.getStorageSync('COOK_U');
            n = 2 == n ? 'yj' : 'qx';
            app.globalData.ajax({
                url: 'my_hongniang.php',
                data: {
                    submitok: 'list',
                    t: n,
                    f: o,
                    openid: t.openid
                },
                success: function (t) {
                    1 == t.flag
                        ? that.setData({
                              NUM: t.NUM,
                              LIST: t.LIST
                          })
                        : uni.showModal({
                              content: t.msg,
                              confirmColor: that.color,
                              confirmText: '朕知道了',
                              showCancel: false,
                              success: function (t) {
                                  uni.navigateBack();
                              }
                          });
                }
            });
        },

        hnFn: function () {
            uni.reLaunch({
                url: '/pages/hn/hn'
            });
        }
    }
};
</script>
<style>
@import 'hongniang.css';
</style>
